package com.changgou.service.goods.service.impl;

import com.changgou.service.goods.mapper.SpecMapper;
import com.changgou.service.goods.service.SpecService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author: Bytezero_zhengLei
 * @Date: 2024/8/26 21:17
 * @Project_Name:
 * @Email: 420498246@qq.com
 * @Description:
 * @TODO:
 */
@Service
public class SpecServiceImpl implements SpecService {

    @Resource
    private SpecMapper specMapper;

    @Override
    public List<Map> findListByCategoryName(String categoryName) {
        List<Map> specList = specMapper.findListByCategoryName(categoryName);
        for (Map spec : specList) {
            String[] options = ((String) spec.get("options")).split(",");//规格选项列表

            spec.put("options", options);
        }
        return specList;
    }


}
